/**
 *******************************************************************************
 * @brief       Provide a brief description of the module here (Single line).
 * 
 * @author      Ashwin
 * 
 * @file        Bitwise_Macros.h
 * 
 * @version     1.0.0
 * 
 * @date        Jan 28, 2012 3:49:14 AM
 * 
 * @details     Provide a detailed description of the module here (Multi-line).
 * 
 * @pre         Mention any preconditions required to use this module.
 * 
 * @bug         List any bugs in this module.
 * 
 * @note        List any odd modes while using this module.
 * 
 * @warning     List any warnings against using the objects of this module.
 *******************************************************************************
 * @copyright 2012
 * <a href="http://www.afflatustech.com">Afflatus Techtronics</a>
 * and <a href="http://www.ashwinvijayakumar.co.nr">Ashwin Vijayakumar</a>
 * @n@n
 * This work is licensed under the Creative Commons
 * Attribution-NonCommercial-ShareAlike 3.0 Unported License. To view a copy
 * of this license, visit http://creativecommons.org/licenses/by-nc-sa/3.0/ or
 * send a letter to Creative Commons, 444 Castro Street, Suite 900, Mountain
 * View, California, 94041, USA.
 *******************************************************************************
 */

/**@cond Include guard symbol - Protect against multiple inclusions  @endcond */

#ifndef BITWISE_MACROS_H_
#define BITWISE_MACROS_H_

/**@cond ***********************************************************************
 * Add #include "Bitwise_Macros.h" in source files that need access to the below
 * listed declarations.
 ******************************************************************* @endcond */

/**@cond -----------------------------------------------------------------------
 * Includes section
 * Add all #include here.
 * ----------------------------------------------------------------- @endcond */

/**@cond System headers -------------------------------------------- @endcond */

/**@cond Local headers --------------------------------------------- @endcond */
#include "Std_Types.h"

/**@cond -----------------------------------------------------------------------
 * typedef section (Project scope)
 * Add typedef's with project scope here.
 * Capitalization: Upper_Camel_Case.
 * ----------------------------------------------------------------- @endcond */

/**@cond -----------------------------------------------------------------------
 * Constants section (Project scope)
 * Add all constants with project scope here.
 * Capitalization: ALL_CAPS.
 * ----------------------------------------------------------------- @endcond */

/* Standard Bit Definitions */
/**
 * @brief Standard Bit Definitions.
 * @details These constants shall be used to reference individual bits of a
 * variable upto 32 bits long.
 * @{
 */

#define  BIT0           0x00000001      /**< BIT0. */
#define  BIT1           0x00000002      /**< BIT1. */
#define  BIT2           0x00000004      /**< BIT2. */
#define  BIT3           0x00000008      /**< BIT3. */
#define  BIT4           0x00000010      /**< BIT4. */
#define  BIT5           0x00000020      /**< BIT5. */
#define  BIT6           0x00000040      /**< BIT6. */
#define  BIT7           0x00000080      /**< BIT7. */
#define  BIT8           0x00000100      /**< BIT8. */
#define  BIT9           0x00000200      /**< BIT9. */
#define  BIT10          0x00000400      /**< BIT10. */
#define  BIT11          0x00000800      /**< BIT11. */
#define  BIT12          0x00001000      /**< BIT12. */
#define  BIT13          0x00002000      /**< BIT13. */
#define  BIT14          0x00004000      /**< BIT14. */
#define  BIT15          0x00008000      /**< BIT15. */
#define  BIT16          0x00010000      /**< BIT16. */
#define  BIT17          0x00020000      /**< BIT17. */
#define  BIT18          0x00040000      /**< BIT18. */
#define  BIT19          0x00080000      /**< BIT19. */
#define  BIT20          0x00100000      /**< BIT20. */
#define  BIT21          0x00200000      /**< BIT21. */
#define  BIT22          0x00400000      /**< BIT22. */
#define  BIT23          0x00800000      /**< BIT23. */
#define  BIT24          0x01000000      /**< BIT24. */
#define  BIT25          0x02000000      /**< BIT25. */
#define  BIT26          0x04000000      /**< BIT26. */
#define  BIT27          0x08000000      /**< BIT27. */
#define  BIT28          0x10000000      /**< BIT28. */
#define  BIT29          0x20000000      /**< BIT29. */
#define  BIT30          0x40000000      /**< BIT30. */
#define  BIT31          0x80000000      /**< BIT31. */

/**
 * @}
 */

/**@cond -----------------------------------------------------------------------
 * Macros section (Project scope)
 * Add all macros with project scope here.
 * Capitalization: ALL_CAPS.
 * ----------------------------------------------------------------- @endcond */

/* Bit Operation Macros */
/**
 * @brief Bit Operation Macros
 * @details These macros shall be used to perform bitwise operations like set,
 * reset, toggle and check individual pins of a port. The macros can perform
 * bitwise operations on multiple pins provided the user ORs all the pins/bits.
 * @note How to use:@n
 * @code
 * SET(PORTA, BIT5)
 * CLR( PORTB, (BIT0 | BIT2 | BIT5) )
 * if((CHK(PORTD, BIT4) == 0)
 *      Condition will be TRUE if PORTD.4 is @ logic low level.
 * @endcode
 * @{
 */

#define SET(PxOUT, BIT) (PxOUT |= BIT)  /**< Set PxOUT.BIT to Logic High */
#define CLR(PxOUT, BIT) (PxOUT &= ~BIT) /**< Reset PxOUT.BIT to Logic Low */
#define CHK(PxIN, BIT)  (PxIN & BIT)    /**< Check if PxIN.BIT is Logic Low */
#define TOG(PxOUT, BIT) (PxOUT ^= BIT)  /**< Toggle PxOUT.BIT between Logic Low and Logic High */

/**
 * @}
 */

/**@cond -----------------------------------------------------------------------
 * Global variables section (Project scope)
 * Add global variables with project scope here. 
 * Capitalization: lower_case.
 * Declare them with 'extern' keyword.
 * ----------------------------------------------------------------- @endcond */

/**@cond -----------------------------------------------------------------------
 * Function prototypes section (Project scope)
 * Add prototypes for all functions with project scope here. 
 * Capitalization: lower_Camel_Case.
 * ----------------------------------------------------------------- @endcond */

/**@cond -----------------------------------------------------------------------
 * Getter/setter prototype section (Project scope)
 * Add prototypes for getter/setter methods here.
 * Capitalization: get_Camel_Case/is_Camel_Case/set_Camel_Case. 
 * ----------------------------------------------------------------- @endcond */


#endif /* BITWISE_MACROS_H_ */


/** END OF FILE ********************* Copyright (C) 2012 Afflatus Techtronics */
